import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Patch,
  Post,
  Put,
  Req,
} from '@nestjs/common';
import { FriendService } from './friend.service';
import { AddFriendDto, MoveFriendDto, UpdateGroupDto } from './friend.dto';

@Controller('friend')
export class FriendController {
  constructor(private readonly friendService: FriendService) {}

  //查看好友列表
  @Get('/list')
  getGroupsWithFriends(@Req() req) {
    const userId = req.user.user_id as number;
    return this.friendService.getFriends(userId);
  }

  //添加好友
  @Post('/:friendId')
  addFriend(@Req() req, @Param('id') id: string) {
    const userId = req.user.user_id as number;
    const friendId = id as unknown as number;
    return this.friendService.addFriend(userId, friendId);
  }

  //搜索朋友

  //修改备注：看时间

  //删除好友
  @Delete('/:friendId')
  deleteFriend(@Req() req, @Param('friendId') friendId: string) {
    const userId = req.user.user_id as number;
    return this.friendService.deleteFriend(userId, parseInt(friendId));
  }
}
